module cl {
	export class MoveRemainAction extends ActionPerformer {
		constructor() {
			super();
			this.type = 3;
			this.paramKeys = JSON.stringify([]);
			this.paramVals = JSON.stringify([]);
		}

		public accept() : void {
			for (let troopid = 0; troopid < Math.min(Campaign.troop.length, this.other_m_remain.length); troopid++){
				if (Campaign.troop_plane[troopid] >= 0) {
					Campaign.troop[troopid].move_remain = this.other_m_remain[troopid];
				}
			}
		}

		public acceptOnce() : void { this.accept(); }

		public duration() : number {
			return 500;
		}

		public play(map : CampaignPage) : void {
			for (let troopid = 0; troopid < Campaign.troop.length; troopid++){
				if (Campaign.troop_plane[troopid] >= 0) {
					let troopGroup = (Campaign.troop_plane[troopid] > 0? map.groupCourtTroop : map.groupTroop).getChildByName(String(troopid)) as eui.Group;
					let ratio = this.other_m_remain[troopid] / Campaign.troop[troopid].move;
            		map.troopManager.drawMoveRemain(troopGroup, ratio);
				}
			}
        }
	}
}